//
//  HMSettingViewController.m
//  01-网易彩票
//
//  Created by SZSYKT_iOSBasic_2 on 16/2/20.
//  Copyright © 2016年 heima. All rights reserved.
//

#import "HMSettingViewController.h"
#import "HMOneViewController.h"
#import "HMPushRemindController.h"
#import "HMHelpViewController.h"
#import "HMProductViewController.h"
#import "HMShareViewController.h"
#import "HMAboutViewController.h"
@implementation HMSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 设置标题
    self.title = @"设置";
    // 创建三个组模型
    // 创建第1组
    HMSettingItem *item10 = [HMSettingItemArrow itemWithTitle:@"使用兑换码" icon:@"RedeemCode" destVc:[HMOneViewController class]];
    HMSettingGroup *group1 = [HMSettingGroup groupWithItems:@[item10]];
    
    // 创建第2组
    HMSettingItem *item21 = [HMSettingItemArrow itemWithTitle:@"推送提醒" icon:@"MorePush" destVc:[HMPushRemindController class]];
    
    HMSettingItem *item22 = [HMSettingItemSwitch itemWithTitle:@"摇一摇机选" icon:@"handShake"];
    HMSettingItem *item23 = [HMSettingItemSwitch itemWithTitle:@"声音效果" icon:@"sound_Effect"];
    HMSettingItem *item24 = [HMSettingItemSwitch itemWithTitle:@"购彩小助手" icon:@"More_LotteryRecommend"];

    HMSettingGroup *group2 = [HMSettingGroup groupWithItems:@[item21,item22,item23,item24]];
    
    // 创建第3组
    HMSettingItem *item31 = [HMSettingItemArrow itemWithTitle:@"检查新版本" icon:@"MoreUpdate"];
    item31.operationBlock = ^{
        [MBProgressHUD showMessage:@"正在检查更新..."];
        // 在实际开发中，该地方写发送网络请求的代码
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [MBProgressHUD hideHUD];
            [MBProgressHUD showSuccess:@"当前是最新版本"];
        });
    };
    
    
    HMSettingItem *item32 = [HMSettingItemArrow itemWithTitle:@"帮助" icon:@"MoreHelp" destVc:[HMHelpViewController class]];
    HMSettingItem *item33 = [HMSettingItemArrow itemWithTitle:@"分享" icon:@"MoreShare" destVc:[HMShareViewController class]];
    HMSettingItem *item34 = [HMSettingItemArrow itemWithTitle:@"产品推荐" icon:@"MoreNetease" destVc:[HMProductViewController class]];
    HMSettingItem *item35 = [HMSettingItemArrow itemWithTitle:@"关于" icon:@"MoreAbout" destVc:[HMAboutViewController class]];
    HMSettingGroup *group3 = [HMSettingGroup groupWithItems:@[item31,item32,item33,item34,item35]];
    // 将组模型添加到数组中
    self.groups = [NSMutableArray arrayWithObjects:group1,group2,group3, nil];
}
@end
